from DB import MySQLUtils

# 定义要循环的数组
actions = ['卖掉了', '不卖了', '空号', '下架', '停机', '只租']

# 循环数组中的每个元素
for action in actions:
    dbUtil = MySQLUtils.DBUtil()

    # 拼装查询 SQL
    select_query = f"SELECT house_id FROM house_follow hf WHERE content LIKE '%{action}%'"

    # 执行查询
    house_ids = dbUtil.get_all(select_query)

    # 循环 house_ids 列表
    for house_id in house_ids:
        # 拼装更新 SQL
        update_query = f"UPDATE house SET is_del = 1 WHERE house_id = {house_id}"

        # 执行更新操作
        dbUtil.save(update_query)

        print(update_query)

print("更新操作完成")
